package com.TTBook.utils.security;

import org.springframework.security.providers.encoding.Md5PasswordEncoder;

/**
 * <p>MD5 implementation of PasswordEncoder.</p>
 * <p>If a <code>null</code> password is presented, it will be treated as an empty <code>String</code> ("")
 * password.</p>
 * <P>As MD5 is a one-way hash, the salt can contain any characters.</p>
 *
 * This is a convenience class that extends the
 * {@link MessageDigestPasswordEncoder} and passes MD5 as the algorithm to use.
 *
 * @author Ray Krueger
 * @author colin sampaleanu
 * @author Ben Alex
 * @version $Id: Md5PasswordEncoder.java 2217 2007-10-27 00:45:30Z luke_t $
 */
public class IgnoreCaseMd5PasswordEncoder extends Md5PasswordEncoder {

    public IgnoreCaseMd5PasswordEncoder() {
    }
    /**
     * encPass 数据库加密的密码
     * rawPass 用户输入的密码(明码)
     */
    public boolean isPasswordValid(String encPass, String rawPass, Object salt) {
        String pass1 = "" + encPass;
        String pass2 = encodePassword(rawPass.toLowerCase(), salt);
        return pass1.equalsIgnoreCase(pass2);
    }
}
